import {defineStore} from 'pinia';

export const userPageStateStore = defineStore('pageState', {
    ///
    ///防止动作的方法
    actions:{
        add(){
            ///存到本地浏览器
            ///关掉浏览器也存在
            // localStorage.setItem('',JSON.stringify([]));
            ///获取本地浏览器的数据
            // JSON.parse(localStorage.getItem('talkList') as string || []) ;
            ///直接赋值
            this.mainTopMenuSelectedIndex=2;
            console.log('@@@',this.$state.mainTopMenuSelectedIndex);
            /// this.打印
            ///console.log(this.mainTopMenuSelectedIndex);
            ////直接赋值
            // userPageStateStore.$patch({
            //     mainTopMenuSelectedIndex:100,
            // });

        }
    },
    ///存数据的地方
    state: () => {
        return {
            ///主页默认选择的标签
            mainTopMenuSelectedIndex: 0
        }
    },
    ///有点像Computer计算
    getters:{
        bigSum(state){
            return state.mainTopMenuSelectedIndex*10;
        }
    }
},);